import sys
import os


class FilesClass:
    dir = []

    def __init__(self):
        res = os.popen("ls -al ./files")
        for i in res:
            data = i.split(" ")
            try:
                if data[-1].strip() != "." and data[-1].strip() != "..":
                    self.dir.append(data[-1].strip())
            except:
                pass
        self.dir.pop(0)

    def show_dir(self):
        for i in range(len(self.dir)):
            print(f"{i + 1}:" + self.dir[i])

    def read_file_to_byte(self, seq: int):
        test = open(f"./files/{self.dir[seq-1]}", mode="rb+")
        file_byte = test.read()
        test.close()
        return file_byte


# file = FilesClass()
# file.show_dir()
# file.read_file_to_byte()
